package cn.zorbus.oss.impl;

import com.qiniu.util.Auth;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * create in 2024/11/7 23:44
 *
 * @author shishaodong
 * @version 0.0.1
 */
@Configuration
@ConditionalOnProperty(prefix = "cn.zorbus.oss.qi-niu", name = "access-key")
public class QiNiuConfig {

    @Bean
    public OssTemplateQiNiuImpl ossTemplateQiniuImpl(Auth auth) {
        return new OssTemplateQiNiuImpl(auth);
    }

    @Bean
    public QiNiuProperties qiNiuProperties() {
        return new QiNiuProperties();
    }

    @Bean
    public Auth auth(QiNiuProperties properties) {
        return Auth.create(properties.getAccessKey(), properties.getSecretKey());
    }
}
